package com.zzjson.design.proxy.custom;

import java.lang.reflect.Method;

/**
 * <p>****************************************************************************</p>
 * <p><b>Copyright © 2010-2018 rollBall team All Rights Reserved<b></p>
 * <ul style="margin:15px;">
 * <li>Description : cn.gson.aop</li>
 * <li>Version     : 1.0.0</li>
 * <li>Creation    : 2018年11月30日</li>
 * <li>@author     : zzy0_0</li>
 * </ul>
 * <p>****************************************************************************</p>
 */
public class MeiPo implements MyInvocationHandler {
    private Person target;


    //获取被代理人的资料
    public Object getInstance(Person target) throws Exception {
        this.target = target;
        Class clazz = target.getClass();
        System.out.println("被代理的对象是=" + clazz);
        return MyProxy.newProxyInstance(new MyClassLoader(), clazz.getInterfaces(), this);
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        //System.out.println("性别" + this.target.getSex());
        System.out.println("海选");
        //this.target.findLove();
        method.invoke(this.target, args);
        System.out.println("dd");
        return null;
    }
}